package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 谈判 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=1010;
       static int a[]=new int[N],n;
       
       public static void main(String[] ss) throws IOException {
		      n=Integer.parseInt(br.readLine());
		      if(n==1){
		    	  System.out.print(0);
		    	  return;
		      }
		      ss=br.readLine().split(" ");
		      for(int i=1;i<=n;i++)
		    	  a[i]=Integer.parseInt(ss[i-1]);
		      Arrays.sort(a,1,n+1);
		      for(int i=1;i<=n;i++)
		    	  a[i]=a[i-1]+a[i];
		      long res=0;
		      for(int i=2;i<=n;i++)
		    	  res+=a[i];
		      System.out.print(res);
	}
}
